using System.Collections.Generic;
using System.IO;

namespace Lottery.Client.SL
{
    public class LotteryInfos
    {
        public static LotteryInfo GetLotteryInfo(BinaryReader br)
        {
            LotteryInfo result;
            try
            {
                result = new LotteryInfo
                             {
                                 ID = br.ReadInt32(),
                                 Name = br.ReadString(),
                                 OpenChase = br.ReadBoolean()
                             };
            }
            catch
            {
                result = null;
            }
            return result;
        }
        public static string GetLotteryName(int lotteryid)
        {
            using (List<LotteryInfo>.Enumerator enumerator = DataCache.LotteryDatas.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    LotteryInfo current = enumerator.Current;
                    if (current.ID == lotteryid)
                    {
                        return current.Name;
                    }
                }
            }
            return "";
        }
    }
}